package com.ymatou.iapi.im.testcase;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;




import com.ymatou.iapi.im.parameter.SendMessageToBuyerBean;
import com.ymatou.iapi.im.service.SendMessageToBuyerCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;

public class Ts_SendMessageToBuyer {
	public static SendMessageToBuyerCall sendcall;
    public static SendMessageToBuyerBean sendbean;
    
    @BeforeClass
	public static void setUp() {
		Logger.createResultFile("IM java接口");
	}

	@Before
	public void caseUp() {
		sendcall = new SendMessageToBuyerCall();
		sendbean = new SendMessageToBuyerBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SendMessageToBuyer_001(){
		try {
			Logger.start(true, "买手向买家发送一条消息，发送成功");
			sendbean.setAppId("app.ymatou.com");
			sendbean.setFromUserId(3383);
			sendbean.setToUserId(4085);
			sendbean.setMessage("我是买手");
			sendbean.setNeddAutoReply(false);
			sendbean.setIsAutoReply(false);
			sendbean.setSessionNumber("3383_4085");
			sendbean.setAutoSetRead(true);
			sendbean.setCSId(4085);
			sendbean.setCSName("lunchzhao");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals("Success", new JSONObject(sendcall.getReturnData()).getString("Status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SendMessageToBuyer_002(){
		try {
			Logger.start(true, "买手向买家发送图片，发送成功");
			sendbean.setAppId("app.ymatou.com");
			sendbean.setFromUserId(3383);
			sendbean.setToUserId(4085);
			sendbean.setMessage("[img]http://pic1.ymatou.com/G01/M00/2F/5D/rBBlD1hg8JqAcw_pAAOQn3fB5wk437_8_5_o.jpg#274x171[/img]");
			sendbean.setNeddAutoReply(false);
			sendbean.setIsAutoReply(false);
			sendbean.setSessionNumber("3383_4085");
			sendbean.setAutoSetRead(true);
			sendbean.setCSId(4085);
			sendbean.setCSName("lunchzhao");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals("Success", new JSONObject(sendcall.getReturnData()).getString("Status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SendMessageToBuyer_003(){
		try {
			Logger.start(true, "买家向买手发送表情，发送成功");
			sendbean.setAppId("app.ymatou.com");
			sendbean.setFromUserId(3383);
			sendbean.setToUserId(4085);
			sendbean.setMessage("😁");
			sendbean.setNeddAutoReply(false);
			sendbean.setIsAutoReply(false);
			sendbean.setSessionNumber("3383_4085");
			sendbean.setAutoSetRead(true);
			sendbean.setCSId(4085);
			sendbean.setCSName("lunchzhao");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals("Success", new JSONObject(sendcall.getReturnData()).getString("Status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_SendMessageToBuyer_004(){
		try {
			Logger.start(true, "买手向买家发送特殊字符，发送成功");
			sendbean.setAppId("app.ymatou.com");
			sendbean.setFromUserId(3383);
			sendbean.setToUserId(4085);
			sendbean.setMessage("！）（*&……@￥测试测试导出");
			sendbean.setNeddAutoReply(false);
			sendbean.setIsAutoReply(false);
			sendbean.setSessionNumber("3383_4085");
			sendbean.setAutoSetRead(true);
			sendbean.setCSId(4085);
			sendbean.setCSName("lunchzhao");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals("Success", new JSONObject(sendcall.getReturnData()).getString("Status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Ts_SendMessageToBuyer_005(){
		try {
			Logger.start(true, "内容为空  发送失败");
			sendbean.setAppId("app.ymatou.com");
			sendbean.setFromUserId(4085);
			sendbean.setToUserId(3383);
			sendbean.setMessage(null);
			sendbean.setNeddAutoReply(false);
			sendbean.setIsAutoReply(false);
			sendbean.setSessionNumber("3383_4085");
			sendbean.setAutoSetRead(true);
			sendbean.setCSId(3383);
			sendbean.setCSName("wesper");
			sendcall.setData(sendbean);
			sendcall.callService();
			Logger.verifyEquals("ParameterError", new JSONObject(sendcall.getReturnData()).getString("Status"), "响应报文-返回码");
		}
		catch(Exception e ) {
			Logger.fail(e);
		}
		
		
		
	}

}
